home *** CD-ROM | disk | FTP | other *** search
/ autolist.mesd.k12.or.us / autolist.mesd.k12.or.us.zip / autolist.mesd.k12.or.us / antivirus / mcafee-macosx.dmg / VirusScan Uninstall.command < prev   
Text File  |  2008-10-13  |  11KB  |  357 lines

  1. #!/bin/sh 
  2.  
  3. #################################################################
  4. #
  5. # VirusScan for Mac Uninstall.command
  6. # Copyright (c) 2008 McAfee, Inc. All Rights Reserved.
  7. #
  8. ################################################################
  9. delete()
  10. {   
  11.  if [ $# -ne 1 ] ; then
  12.     echo "Invalid no of arguments passed to function delete "
  13.     return
  14.  fi
  15.  if [ -s "${1}" ] ; then 
  16.  sudo rm -rf "${1}"
  17.  fi 
  18. }
  19. uninstallnwa()
  20. {
  21. if [ -s "/Library/NETAepoagt" ] ; then 
  22.  sudo SystemStarter stop nwa
  23. echo "removing nwa components"
  24. for i in /Library/Receipts/NWA.pkg /Library/NETAepoagt /Library/StartupItems/nwa /Applications/Utilities/ePO\ Agent\ Configurator.app /Library/NETASSOC
  25.   do
  26. delete "$i"
  27. done
  28. fi 
  29. }
  30.  
  31. deletelink()
  32. {
  33.  if [ $# -lt 1 ] ; then
  34.     echo "Invalid no of arguments passed to function delete "
  35.     return
  36.  fi
  37.  if [ -L "${1}" ] ; then 
  38.  sudo rm -rf "${1}"
  39.  fi 
  40.  
  41. }
  42. deleteHotfixes()
  43. {
  44. # the deletion of hotfix receipts is on the assumption that hotfix gets installed in name VirusscanHf_______.pkg
  45. #TODO do some checkin 
  46. sudo rm -rf /Library/Receipts/VirusScanHF*
  47.  
  48. }
  49.  
  50. killvirex77process()
  51. {
  52.  
  53. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShieldBkgd" ) {print $1}  }'`
  54. sudo kill -1 ${pid} 2>/dev/null
  55.  
  56. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShield" ) {print $1}  }'`
  57. sudo kill -1 ${pid} 2>/dev/null
  58.  
  59. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShieldMount" ) {print $1}  }'`
  60. sudo kill -1 ${pid} 2>/dev/null
  61.  
  62.  
  63. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VirexLogin" ) {print $1}  }'`
  64. sudo kill -1 ${pid} 2>/dev/null
  65.  
  66.  
  67. pid=`ps -ax -o "pid" -o "command" | grep -i "/Applications/Virex.app/Contents/MacOS/Virex" | grep -v grep | awk '{print $1}'`
  68. sudo kill -1 ${pid} 2>/dev/null
  69.  
  70.  pid=`ps -ax -o "pid" -o "command" | grep -i "Virex Schedule Editor" | grep -v grep | awk '{print $1}'`
  71. sudo kill -1 ${pid} 2>/dev/null
  72.  
  73. }
  74.  
  75. shutdownprocess()
  76. {
  77. # Kill Process after unloading from launchd 
  78. echo "Shutting down VirusScan Daemons..."
  79.  
  80. pid=`ps -a -U root -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShieldScanManager" ) {print $1}  }'`
  81. sudo kill -1 ${pid} 2>/dev/null
  82.  
  83.  
  84. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/Applications/VirusScan.app/Contents/MacOS/VirusScan" ) {print $1}  }'`
  85. sudo kill -1 ${pid} 2>/dev/null
  86.  
  87. pid=`ps -ax -o "pid" -o "command" | grep "VShieldTaskManager" | grep -v grep | awk '{print $1}'`
  88. sudo kill -1 ${pid} 2>/dev/null
  89.  
  90. pid=`ps -ax -o "pid" -o "command" | grep "VirusScan Schedule Editor" | grep -v grep | awk '{print $1}'`
  91. sudo kill -1 ${pid} 2>/dev/null
  92.  
  93. pid=`ps -ax -o "pid" -o "command" | grep -i "/Library/Application Support/Virex/VirusScan Reporter" | grep -v grep | awk '{print $1}'`
  94. sudo kill -1 ${pid} 2>/dev/null
  95.  
  96. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShieldScanner" ) {print $1}  }'`
  97. sudo kill -1 ${pid} 2>/dev/null
  98.  
  99. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/Applications/Utilities/VirusScan" ) {print $1}  }'`
  100. sudo kill -1 ${pid} 2>/dev/null
  101.  
  102. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "usr/local/vscanx/VirusScan" ) {print $1}  }'`
  103. sudo kill -1 ${pid} 2>/dev/null
  104.  
  105. # kill the previous process
  106. pid=`ps -a -U root -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShieldScan" ) {print $1}  }'`
  107. sudo kill -1 ${pid} 2>/dev/null
  108.  
  109.  
  110. pid=`ps -a -U root -o "pid" -o "command" | awk -F " " '{ if ( $2 == "./VShieldEPOInterface" ) {print $1}  }'`
  111. sudo kill -3 ${pid} 2>/dev/null
  112. sudo kill -9 ${pid} 2>/dev/null
  113.  
  114. pid=`ps -a -U root -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShieldCheck" ) {print $1}  }'`
  115. sudo kill -1 ${pid} 2>/dev/null
  116.  
  117. pid=`ps -a -U root -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShieldCore" ) {print $1}  }'`
  118. sudo kill -1 ${pid} 2>/dev/null
  119.  
  120.  
  121. pid=`ps -a -U root -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VShieldUpdate" ) {print $1}  }'`
  122. sudo kill -1 ${pid} 2>/dev/null
  123.  
  124. pid=`ps -ax -o "pid" -o "command" | awk -F " " '{ if ( $2 == "/usr/local/vscanx/VirexLogin.app/Contents/MacOS/VirexLogin" ) {print $1}  }'`
  125. sudo kill -1 ${pid} 2>/dev/null
  126.  
  127. #removing reporter
  128. pid=`ps -ax -o "pid" -o "command" | awk '{ if ( $2$3 == "/Library/ApplicationSupport/Virex/VirusScan" ) {print $1}  }'`
  129. sudo kill -1 ${pid} 2>/dev/null
  130.  
  131. sudo kextunload "/System/Library/Extensions/Virex.kext" 2>/dev/null
  132. sudo kextunload "/usr/local/vscanx/Extensions/Virex.kext" 2>/dev/null
  133.  
  134. killvirex77process
  135.  
  136. }
  137.  
  138. virex861()
  139. {
  140. delete "/private/etc/cma.d/VSCANMAC8610"
  141. }
  142.  
  143.  
  144. virex86()
  145. {
  146. echo   "Cleaning Scheduled Tasks..."
  147. sudo /usr/local/vscanx/VSCronCleaner 2>/dev/null
  148.  
  149. echo   "Removing VirusScan Application Folders..."
  150. delete "/Applications/PreferencesApp.app"
  151. delete "/Applications/VirusScan.app"
  152. delete "/Applications/Utilities/VirusScan Schedule Editor.app"
  153. delete "/etc/mach_init_per_user.d/virex_login.plist"
  154. delete "/usr/local/vscanx"
  155. delete "/usr/share/man/man1/uvscan.1"
  156.  
  157. echo "Removing VirusScan Support files..."
  158. delete "/Library/LaunchDaemons/com.mcafee.virusscan.ScanManager.plist"
  159. delete "/Library/LaunchDaemons/com.mcafee.virusscan.eupdate.plist"
  160. delete "/Library/LaunchDaemons/com.mcafee.virusscan.VShieldEPOInterface.plist"
  161. delete "/Library/LaunchAgents/com.mcafee.virusscan.VirusScanReporter.plist"
  162.  
  163. delete "/Library/Application Support/Virex/com.mcafee.virex.update_mod.plist"
  164. delete "/Library/Application Support/Virex/com.mcafee.virex.eupdate.plist"
  165. delete "/Library/Application Support/Virex/digest.plist"
  166. delete "/Library/Application Support/Virex/.DS_Store"
  167. sudo rm -rf "/Library/Application Support/Virex" 2>/dev/null
  168.  
  169. echo "Removing VirusScan Engine..." 
  170.  
  171. delete "/Library/Frameworks/AVEngine.framework"
  172. delete "/Library/Frameworks/MacScanner.framework"
  173. delete "/Library/Receipts/VirusScan.pkg"
  174. delete "/Library/Frameworks/VirusScanPreferences.framework"
  175. delete "/Library/Frameworks/ScanBooster.framework"
  176. delete "/Library/NETASSOC/VSCANMAC8600"
  177.  
  178. echo "Removing VirusScan Support Documentation..."
  179.  
  180. delete "/Library/Documentation/Help/VirusScanHelp.help"
  181.  
  182. VAR=`dscl . -list /Groups | grep -w Virex`
  183. if [ ! -z $VAR ]
  184. then
  185. echo "y" | sudo dseditgroup -o delete Virex > /dev/null
  186. fi
  187.  
  188. echo "Cleaning up..."
  189.  
  190. if [ -x "/usr/local/vscanx/Extensions/Virex.kext" ]; then
  191.     sudo rm -rf "/usr/local/vscanx/Extensions/Virex.kext"
  192. fi
  193.  
  194. line=$(grep -n "VirusScan.log" /etc/syslog.conf | cut -d: -f1 | sed '1q')
  195. if [ -n "$line" ]; then
  196. sudo sed ${line}d /etc/syslog.conf > /tmp/syslog.new
  197. sudo mv /tmp/syslog.new /etc/syslog.conf
  198. sudo chown root /etc/syslog.conf
  199. fi
  200. }
  201.  
  202. virex851()
  203. {
  204. delete "/Library/Frameworks/VShieldHelper.framework"
  205. delete "/Library/NETASSOC/VIREXUB_8501"
  206. delete "/Library/StartupItems/Virex"
  207. delete "/Library/StartupItems/VShieldEPOInterface"
  208.  
  209. if [ -x "/System/Library/Extensions/Virex.kext" ]; then
  210.     sudo rm -rf "/System/Library/Extensions/Virex.kext"
  211. fi
  212. }
  213.  
  214. virex85()
  215. {
  216. delete  "/Library/NETASSOC/VIREXUB_8500"
  217. }
  218.  
  219. virex80()
  220. {
  221. delete "/Library/NETASSOC/VRXMCTEL8000"
  222. }
  223.  
  224. virex77()
  225. {
  226.  delete "/Applications/Virex.app"
  227.  delete "/Applications/Utilities/Virex Schedule Editor.app"
  228.  delete "/Library/NETASSOC/VIREX___7600"
  229.  delete "/Library/NETASSOC/VIREX___7700"
  230.  delete "/Library/NETASSOC/VRXMCTEL8500"
  231.  delete "/Library/Receipts/Virex.pkg"
  232.  delete "/Library/Documentation/Help/VirexHelp.help"
  233.  delete "/usr/share/man/man1/VShieldStatus.1"
  234.  
  235. }
  236.  
  237. virex72()
  238. {       delete "/Library/Application Support/Virex/VShieldExclude.txt"
  239.     delete "/Applications/Virex 7"
  240.     delete "/usr/local/share/man/man1/vscanx.1"
  241.     delete "/Library/Documentation/Help/Virex Help"
  242.     delete "/Library/Documentation/Help/Virex7.Help"
  243.     delete "/Library/Documentation/Help/Virex 7.1 Help"
  244.     delete "/Library/Documentation/Help/Virex 7.2 Help"
  245.     delete "/Library/Documentation/Help/VirexHelp.help"
  246.     delete "/Library/Receipts/Virex7.pkg"
  247.     delete "/Library/Receipts/Virex 7.1.pkg"
  248.     delete "/Library/Receipts/Virex 7.1 Trial.pkg"
  249.     delete "/Library/Receipts/Virex 7.2.pkg"
  250.     delete "$HOME/Library/Preferences/VirexPrefs.vprF"
  251.     delete "${HOME}/Library/Preferences/com.nai.virex.plist"
  252.     delete "${HOME}/Library/Preferences/com.nai.virex71.plist"
  253.     delete "${HOME}/Library/Preferences/com.nai.virex72.plist"
  254.  
  255. }
  256.  
  257. StopVirexDaemons()
  258. {
  259.     sudo launchctl stop com.mcafee.virusscan.eupdate  2>/dev/null
  260.     sudo launchctl stop com.mcafee.virusscan.VShieldEPOInterface  2>/dev/null
  261.     sudo launchctl stop com.mcafee.virusscan.ScanManager  2>/dev/null
  262.     
  263.     #Close reporter for both type of instance running as a root and running as a normal user
  264.     sudo launchctl stop com.mcafee.virusscan.VirusScanReporter  2>/dev/null
  265.     launchctl stop com.mcafee.virusscan.VirusScanReporter  2>/dev/null
  266. }
  267.  
  268. UnloadVirexDaemons()
  269. {
  270.     sudo launchctl unload /Library/LaunchDaemons/com.mcafee.virusscan.eupdate.plist  2>/dev/null
  271.     sudo launchctl unload /Library/LaunchDaemons/com.mcafee.virusscan.VShieldEPOInterface.plist  2>/dev/null
  272.     sudo launchctl unload /Library/LaunchDaemons/com.mcafee.virusscan.ScanManager.plist  2>/dev/null
  273.     sudo launchctl unload /Library/LaunchAgents/com.mcafee.virusscan.VirusScanReporter.plist  2>/dev/null
  274.     launchctl unload /Library/LaunchAgents/com.mcafee.virusscan.VirusScanReporter.plist  2>/dev/null
  275. }
  276.  
  277. OldPreferenceDelete()
  278. {
  279. delete /Library/Preferences/com.nai.virex75.prefs.plist
  280. #TODO add the other not supported pref files
  281.  
  282. }
  283.  
  284. # uninstaller is also used as preflight if number of input is greater than 2 then we can assume that uninstaller is called by preflight hence do not echo uninstall VirusScan for Mac 
  285. if [ $# -lt 2 ] 
  286. then
  287. echo "VirusScan for Mac Uninstall"
  288. echo "-------------------"
  289. echo "This will uninstall VirusScan for Mac."
  290. fi
  291.  
  292. usercheck=`id | grep uid=0 | wc -l`
  293. if [ "$usercheck" -eq 0 ] ; then
  294. echo " If you wish to proceed, authenticate below"
  295. echo " or close this window if you wish to cancel."
  296. fi
  297. # sudo -k
  298. sudo echo ""
  299. val=$?
  300. if [ $val -ne 0 ]
  301. then
  302.     echo "permission denied"
  303.     exit -1
  304. fi
  305. if [ $# -lt 2 ]; then 
  306. echo "Uninstalling VirusScan ..."
  307. cd /
  308. else
  309. uninstallnwa
  310. # uninstall nwa from our preflight
  311. fi
  312.  
  313.  
  314.  
  315. # Stop all the daemons that are currently running
  316. StopVirexDaemons
  317.  
  318. # Unloading  all the daemons that are currently running
  319. UnloadVirexDaemons
  320.  
  321. # call kill process here #TODO Proper Shutdown
  322. shutdownprocess
  323.  
  324. #killvirex77process
  325.  
  326. # delete files related to 8.6.1
  327. virex861
  328.  
  329. # delete files related to 8.6
  330. virex86
  331.  
  332. # delete files related to 8.5.1
  333. virex851
  334.  
  335. # delete files related to 8.5
  336. virex85
  337.  
  338. # delete files related to 8.0
  339. virex80
  340.  
  341. # delete files related to 7.7
  342. virex77
  343.  
  344. # delete files related to 7.2
  345. virex72
  346.  
  347. # delete files related to old preferences
  348. OldPreferenceDelete
  349.  
  350. # remove  Library receipts files for Hotfixes installed
  351. deleteHotfixes
  352.  
  353. if [ $# -lt 2 ]; then 
  354. echo " "
  355. echo "VirusScan has been successfully uninstalled."
  356. fi
  357.